package com.zwb.service.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zwb.service.mapper.MenuMapper;
import com.zwb.service.pojo.Menu;
import com.zwb.service.service.IMenuService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 服务实现类
 * </p>
 *
 * @author zwb
 * @since 2022-08-23
 */
@Service
public class MenuServiceImpl extends ServiceImpl<MenuMapper, Menu> implements IMenuService {


    @Autowired(required = false)
    private MenuMapper enumMapper;

    /**
     * 通过用户id获取菜单列表
     *
     * @param id
     * @return
     */
    @Override
    public List<Menu> getMenusByAdminId(Integer id) {
        return enumMapper.getMenusByAdminId(id);
    }

    /**
     * 根据角色获取菜单列表
     *
     * @return
     */
    @Override
    public List<Menu> getMenusByRole() {

        //TODO 这里可以做缓存优化操作
        return enumMapper.getMenusByRole();
    }

    /**
     * 获取所有菜单（已经排序）
     *
     * @return
     */
    @Override
    public List<Menu> getMenusAll() {
        return enumMapper.getMenusAll();
    }
}
